package xin.petstore.framework.web.img;

import com.google.code.kaptcha.Constants;
import com.google.code.kaptcha.util.Config;
import com.google.code.kaptcha.util.Configurable;

import java.util.Properties;

public class InitConfigurable extends Configurable {
    private static final  Properties properties = new Properties();
    private static Config config;
    static {
            System.out.println("##==>初始化图片config...");
            properties.setProperty(Constants.KAPTCHA_BORDER, "no");
            properties.setProperty(Constants.KAPTCHA_TEXTPRODUCER_FONT_COLOR, "black");
            properties.setProperty(Constants.KAPTCHA_IMAGE_WIDTH, "90");
            properties.setProperty(Constants.KAPTCHA_IMAGE_HEIGHT, "30");
            properties.setProperty(Constants.KAPTCHA_TEXTPRODUCER_FONT_SIZE, "20");
            properties.setProperty(Constants.KAPTCHA_TEXTPRODUCER_CHAR_LENGTH, "2");
            properties.setProperty(Constants.KAPTCHA_TEXTPRODUCER_FONT_NAMES, "宋体,楷体,微软雅黑");
            properties.setProperty(Constants.KAPTCHA_TEXTPRODUCER_CHAR_SPACE,"2");
            properties.setProperty(Constants.KAPTCHA_OBSCURIFICATOR_IMPL,"com.google.code.kaptcha.impl.ShadowGimpy");
            properties.setProperty(Constants.KAPTCHA_NOISE_IMPL , "com.google.code.kaptcha.impl.NoNoise");
            config = new Config(properties);
            System.out.println("##==>初始化图片config success!");

    }


    private static class InitConfigurableHolder {
        private static final InitConfigurable INSTANCE = new InitConfigurable();
    }
    private InitConfigurable (){}
    public static final InitConfigurable getInstance() {
        return InitConfigurableHolder.INSTANCE;
    }

    public Config getConfig() {
        return config;
    }
}
